import * as types from './../mutation-types.js'

const state = {
  userInfo: {}
}

const getters = {
  userInfo: () => state.userInfo
}

const mutations = {
  [types.SAVE_USER_INFO] (state, userInfo) {
    state.userInfo = userInfo
  }
}

const actions = {
  saveUserInfo ({ commit }, userInfo) { // arguments是context，通过context.state访问局部state，全局是state
    commit(types.SAVE_USER_INFO, userInfo)
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}
